import React from 'react';
import { Route, Redirect } from 'react-router-dom';
// import { setLoginRedirectUrl } from '../actions/loginAction';

class AuthorizedRoute extends React.Component {

  renderRoute = (props) => {
    const { component: Component, ...rest } = this.props;
    // 判断登录并且是否有权限
    let isLogged = true;

    return isLogged ? <Component {...props}/> : <Redirect to="/login"/>
  }

  render() {
    
    return (
      <Route {...rest} render={this.renderRoute} />
    )
  }
}

export default AuthorizedRoute